function r = fixErrorNumber(c, num)
  len = length(c);
  if len < num
    error('error number must be less than length of data');
  end

  r = c;
  posSet = zeros(num,1);
  validPosNum = 0;
  while validPosNum < num
    pos = int(len*rand() + 1);
    if find(posSet == pos) == []
      validPosNum = validPosNum + 1;
      posSet(validPosNum) = pos;
    end
  end
  r(posSet) = ~c(posSet);
endfunction


